<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:pt="http://java.sun.com/jsf/passthrough"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs">
    <h:head>
    </h:head>
    <h:body>
        <ui:composition template="/dataverse_template.xhtml">
            <ui:param name="pageTitle" value="#{DatasetPage.editMode == 'CREATE' ? bundle['dataset.pageTitle'] : DatasetPage.workingVersion.title} - #{DatasetPage.dataset.owner.name}"/>
            <ui:param name="dataverse" value="#{DatasetPage.dataset.owner}"/>
            <ui:param name="dataset" value="#{DatasetPage.dataset}"/>
            <ui:param name="version" value="#{DatasetPage.workingVersion}"/>
            <ui:param name="locked" value="#{DatasetPage.locked}"/>
	    <ui:param name="showMessagePanel" value="#{true}"/>
	    <ui:define name="meta_header">
            <meta name="description" content="#{DatasetPage.description}"/>
            </ui:define>
            <ui:define name="dc_meta_header">
	    <meta name="DC.identifier" content="#{DatasetPage.persistentId}"/>
	    <meta name="DC.type" content="Dataset"/>
	    <meta name="DC.title" content="#{DatasetPage.title}"/>
            <meta name="DC.date" content="#{DatasetPage.workingVersion.publicationDateAsString}"/>
	    <meta name="DC.publisher" content="#{DatasetPage.publisher}" />
            <meta name="DC.description" content="#{DatasetPage.description}" />
	    <ui:repeat var="author" value="#{DatasetPage.datasetAuthors}">
            <meta name="DC.creator" content="#{author}"/>
	    </ui:repeat>
            <ui:repeat var="subject" value="#{DatasetPage.workingVersion.datasetSubjects}">
            <meta name="DC.subject" content="#{subject}"/>
	    </ui:repeat>
	    </ui:define>
	    <ui:define name="jsonld_header">
                <script type="application/ld+json">
                    <h:outputText value="#{DatasetPage.jsonLd}"/>
                </script>
	    </ui:define>
	    <ui:define name="og_header">
                <meta property="og:title" content="#{DatasetPage.title}" />
                <meta property="og:type" content="article" />
                <meta property="og:url" content="#{DatasetPage.dataverseSiteUrl}/dataset.xhtml?persistentId=#{dataset.globalId}" />
                <meta property="og:image" content="#{DatasetPage.dataverseSiteUrl.concat(resource['images/dataverse-icon-1200.png'])}" />
                <meta property="og:site_name" content="#{DatasetPage.publisher}" />
                <meta property="og:description" content="#{(DatasetPage.description.length()>150 ? DatasetPage.description.substring(0,147).concat('...') : DatasetPage.description)}" />
                <ui:repeat var="author" value="#{DatasetPage.datasetAuthors}">
                    <meta property="article:author" content="#{author}" />
                </ui:repeat>
                <meta property="article:published_time" content="#{DatasetPage.workingVersion.publicationDateAsString}" />
	    </ui:define>
            <ui:define name="body">
                <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                <f:metadata>
                    <f:viewParam name="id" value="#{DatasetPage.dataset.id}"/>
                    <f:viewParam name="ownerId" value="#{DatasetPage.ownerId}"/>
                    <f:viewParam name="version" value="#{DatasetPage.version}"/>
                    <f:viewParam name="versionId" value="#{DatasetPage.versionId}"/>
                    <f:viewParam name="persistentId" value="#{DatasetPage.persistentId}"/>
                    <f:viewParam name="showIngestSuccess" value="#{DatasetPage.showIngestSuccess}"/>
                    <f:viewParam name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                    <f:viewParam name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                    <f:viewParam name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                    <f:viewParam name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                    <f:viewParam name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                    <f:viewParam name="fileTag" value="#{DatasetPage.fileTagsFacet}"/>
                    <f:viewAction action="#{dataverseSession.updateLocaleInViewRoot}"/>
                    <f:viewAction action="#{DatasetPage.init}" rendered="true"/>
                    <f:viewAction action="#{dataverseHeaderFragment.initBreadcrumbs(DatasetPage.dataset)}"/>
                    <f:viewAction action="#{EditDatafilesPage.initCreateMode(DatasetPage.editMode, DatasetPage.workingVersion, DatasetPage.newFiles, DatasetPage.selectedFiles)}"/>
                </f:metadata>
                <h:form id="datasetForm">
                    <!-- Header / Button Panel -->
                    <!-- View editMode -->
                    <p:fragment id="topDatasetBlockFragment">
                    <div id="topDatasetBlock" class="row" jsf:rendered="#{empty DatasetPage.editMode}">
                        <div id="actionButtonBlock" class="button-block clearfix" jsf:rendered="#{!widgetWrapper.widgetView}">
                            <div class="btn-group pull-right" jsf:rendered="#{DatasetPage.sessionUserAuthenticated
                                                                              and !DatasetPage.dataset.deaccessioned
                                                                              and DatasetPage.showComputeButton()}">
                                <!-- Compute Button Group -->
                                <button type="button" id="computeBatch" class="btn btn-default btn-compute dropdown-toggle" data-toggle="dropdown">
                                    <span class="glyphicon glyphicon-flash"/> #{bundle['dataset.compute.computeBtn']} <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu pull-left text-left" role="menu">
                                    <li>
                                        <!-- Compute dataset link -->
                                        <h:commandLink action="#{DatasetPage.canComputeAllFiles(false)}">
                                            <h:outputText value="#{bundle['dataset.compute.computeBatchSingle']}"/>
                                        </h:commandLink>
                                    </li>
                                    <li jsf:rendered="#{!DatasetPage.isCartEmpty()}" class="divider"></li>
                                    <li jsf:rendered="#{!DatasetPage.checkCartForItem(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}">
                                        <!-- Add link -->
                                        <p:commandLink action="#{DatasetPage.addItemtoCart(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}"
                                            disabled="#{DatasetPage.locked}" value="#{bundle['dataset.compute.computeBatchAdd']}" update=":datasetForm,:messagePanel">
                                            <h:outputText value="#{bundle['dataset.compute.computeBatchAdd']}"/>
                                        </p:commandLink>
                                    </li>
                                    <ui:fragment rendered="#{!DatasetPage.isCartEmpty()}">
                                        <li jsf:rendered="#{DatasetPage.checkCartForItem(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}">
                                            <!-- Remove link -->
                                            <p:commandLink value="#{bundle['dataset.compute.computeBatchRemove']}" action="#{DatasetPage.removeCartItem(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}" update=":datasetForm,:messagePanel">  
                                                <h:outputText value="#{bundle['dataset.compute.computeBatchRemove']}"/>
                                            </p:commandLink>
                                        </li>
                                        <li>
                                            <!-- List link -->
                                            <p:commandLink title="#{bundle['dataset.compute.computeBatchList']}"
                                                           value="#{bundle['dataset.compute.computeBatchList']}"
                                                           oncomplete="PF('computeBatchListPopup').show();bind_bsui_components();"
                                                           update="computeBatchListPopup">
                                                <h:outputText value="#{bundle['dataset.compute.computeBatchList']}"/>
                                            </p:commandLink>
                                        </li>
                                        <li>
                                            <!-- Clear link -->
                                            <p:commandLink value="#{bundle['dataset.compute.computeBatchClear']}" action="#{DatasetPage.clearCart()}" update=":datasetForm,:messagePanel">  
                                                <h:outputText value="#{bundle['dataset.compute.computeBatchClear']}"/>
                                            </p:commandLink>
                                        </li>
                                        <li>
                                            <!-- Compute batch link -->
                                            <h:outputLink value="#{DatasetPage.cartComputeUrl}" target="_blank">
                                                <h:outputText id="compute-batch-button" value="#{bundle['dataset.compute.computeBatchCompute']}" />
                                            </h:outputLink>
                                        </li>
                                    </ui:fragment>
                                </ul>
                            </div>
                            
                            
                            
                            <div class="btn-group pull-right" jsf:rendered="#{!DatasetPage.dataset.deaccessioned}">
                                <!-- Explore Button Group -->
                                <ui:fragment rendered="#{DatasetPage.datasetExploreTools.size()==1}">
                                    <button type="button" class="btn btn-default btn-explore" onclick="$(this).parent().find( 'li > a' ).trigger( 'click' );">
                                        <span class="glyphicon glyphicon-equalizer"/> #{bundle.explore}
                                    </button>
                                </ui:fragment>
                                <ui:fragment rendered="#{DatasetPage.datasetExploreTools.size()>1}">
                                    <button type="button" class="btn btn-default btn-explore dropdown-toggle" data-toggle="dropdown">
                                        <span class="glyphicon glyphicon-equalizer"/> #{bundle.explore} <span class="caret"></span>
                                    </button>
                                </ui:fragment>

                                <ul class="dropdown-menu pull-left text-left" role="menu">
                                    <!-- Explore tool links -->
                                    <ui:repeat var="tool" value="#{DatasetPage.datasetExploreTools}">
                                        <li>
                                            <h:commandLink action="#{DatasetPage.explore(tool)}">
                                                <h:outputText value="#{tool.displayName}"/>
                                            </h:commandLink>
                                        </li>
                                    </ui:repeat>
                                </ul>
                            </div>

                            
                            
                            <div class="btn-group pull-right" role="group">
                                <!-- Edit/Publish Button Group -->
                                <!-- Publish/Submit for Review/Return to Author Button Group -->
                                <ui:fragment rendered="#{DatasetPage.workingVersion == DatasetPage.dataset.latestVersion
                                                            and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)
                                                            or (DatasetPage.dataset.latestVersion.versionState=='DRAFT'
                                                            and DatasetPage.canUpdateDataset()
                                                            and !permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset))}">
                                    <!-- Publish Buttons -->
                                    <p:commandLink styleClass="btn btn-default btn-access #{DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview ? 'disabled' : ''}" onclick="PF('publishConfirm').show()"
                                                   rendered="#{!DatasetPage.dataset.released
                                                               and DatasetPage.dataset.latestVersion.versionState=='DRAFT' and DatasetPage.dataset.owner.released
                                                               and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}">
                                        <span class="glyphicon glyphicon-globe"/> #{bundle['dataset.publish.btn']}
                                    </p:commandLink>

                                    <p:commandLink styleClass="btn btn-default btn-access #{DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview ? 'disabled' : ''}" onclick="PF('releaseDraft').show()"
                                                   rendered="#{DatasetPage.dataset.released and DatasetPage.dataset.latestVersion.versionState=='DRAFT' and DatasetPage.dataset.owner.released
                                                               and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}">
                                        <span class="glyphicon glyphicon-globe"/> #{bundle['dataset.publish.btn']}
                                    </p:commandLink>

                                    <!-- 4.2.1:  replaced permissionServiceBean.on(DatasetPage.dataset.owner).has('PublishDataverse') with DatasetPage.canPublishDataverse() -->
                                    <p:commandLink styleClass="btn btn-default btn-access #{DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview ? 'disabled' : ''}" onclick="PF('mayNotRelease').show()"
                                                   rendered="#{DatasetPage.dataset.latestVersion.versionState=='DRAFT' and !DatasetPage.dataset.owner.released
                                                               and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)
                                                               and !DatasetPage.canPublishDataverse()}">
                                        <span class="glyphicon glyphicon-globe"/> #{bundle['dataset.publish.btn']}
                                    </p:commandLink>

                                    <p:commandLink styleClass="btn btn-default btn-access #{DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview ? 'disabled' : ''}" onclick="PF('publishParent').show()"
                                                   rendered="#{DatasetPage.dataset.latestVersion.versionState=='DRAFT' and !DatasetPage.dataset.owner.released
                                                               and DatasetPage.canPublishDataverse()
                                                               and (DatasetPage.dataset.owner.owner == null or (DatasetPage.dataset.owner.owner != null and DatasetPage.dataset.owner.owner.released))
                                                               and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}">
                                        <span class="glyphicon glyphicon-globe"/> #{bundle['dataset.publish.btn']}
                                    </p:commandLink>

                                    <p:commandLink styleClass="btn btn-default btn-access #{DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview ? 'disabled' : ''}"
                                                   rendered="#{DatasetPage.dataset.latestVersion.versionState=='DRAFT' and !DatasetPage.dataset.owner.released
                                                               and DatasetPage.canPublishDataverse()
                                                               and (DatasetPage.dataset.owner.owner != null and !DatasetPage.dataset.owner.owner.released)
                                                               and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}"
                                                   onclick="PF('maynotPublishParent').show()">
                                        <span class="glyphicon glyphicon-globe"/> #{bundle['dataset.publish.btn']}
                                    </p:commandLink>
                                    <!-- END: Publish Buttons -->
                                    
                                    <ui:fragment rendered="#{DatasetPage.dataset.latestVersion.versionState=='DRAFT' and DatasetPage.dataset.latestVersion.inReview
                                                               and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}">
                                        <!-- Return to Author Button -->
                                        <button type="button" class="btn btn-default btn-access #{(DatasetPage.locked and !DatasetPage.dataset.latestVersion.inReview) ? 'disabled' : ''}" 
                                                              onclick="PF('sendBackToContributor').show()">
                                            <span class="glyphicon glyphicon-repeat"/> #{bundle['dataset.rejectBtn']}
                                        </button>
                                        <!-- END: Return to Author Button -->
                                    </ui:fragment>

                                    <ui:fragment rendered="#{DatasetPage.workingVersion == DatasetPage.dataset.latestVersion
                                                            and !DatasetPage.datasetLockedInWorkflow
                                                            and DatasetPage.dataset.latestVersion.versionState=='DRAFT'
                                                            and DatasetPage.canUpdateDataset()
                                                            and !permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}">
                                        <!-- Submit for Review Button -->
                                        <button type="button" class="btn btn-default btn-access #{DatasetPage.dataset.latestVersion.inReview or DatasetPage.dataset.locked ? 'disabled' : ''}" 
                                                              onclick="PF('inreview').show()">
                                            <span class="glyphicon glyphicon-globe"/> #{DatasetPage.dataset.latestVersion.inReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn']}
                                        </button>
                                        <!-- End: Submit for Review Button -->
                                    </ui:fragment>
                                </ui:fragment>
                                <!-- END: Publish/Submit for Review/Return to Author Button Group -->
                                
                                <p:commandLink rendered="#{dataverseSession.user.authenticated and !DatasetPage.workingVersion.deaccessioned and DatasetPage.dataset.released}"
                                               styleClass="btn btn-default btn-access"   
                                               action="#{DatasetPage.setShowLinkingPopup(true)}"
                                               oncomplete="PF('linkDatasetForm').show();bind_bsui_components();"
                                               update="@form">
                                    <span class="glyphicon glyphicon-link"/> #{bundle['link']}
                                </p:commandLink>
                                
                                <!-- Edit Button -->
                                <ui:fragment rendered="#{DatasetPage.sessionUserAuthenticated
                                                                                  and DatasetPage.canUpdateDataset()
                                                                                  and !DatasetPage.dataset.deaccessioned}">
                                    <button type="button" id="editDataSet" class="btn btn-default btn-access dropdown-toggle #{DatasetPage.lockedFromEdits ? 'disabled' : ''}" data-toggle="dropdown">
                                        <span class="glyphicon glyphicon-pencil"/> #{bundle['dataset.editBtn']} <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu pull-right text-left" role="menu">
                                        <li>                                           
                                            <h:outputLink value="/editdatafiles.xhtml?datasetId=#{DatasetPage.dataset.id}&#38;mode=UPLOAD">
                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.upload']}"/>
                                            </h:outputLink>
                                        </li>
                                        <li>
                                            <p:commandLink id="editMetadata" actionListener="#{DatasetPage.edit('METADATA')}" update="@form,:datasetForm,:messagePanel" oncomplete="javascript:bind_bsui_components();">
                                                <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.metadata']}" />
                                            </p:commandLink>
                                        </li>
                                        <li>
                                            <p:commandLink id="editTerms" actionListener="#{DatasetPage.edit('LICENSE')}" update="@form,:datasetForm,:messagePanel" oncomplete="javascript:bind_bsui_components();">
                                                <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.terms']}" />
                                            </p:commandLink>
                                        </li>
                                        <ui:fragment rendered="#{permissionsWrapper.canManagePermissions(DatasetPage.dataset)}">
                                            <li class="#{settingsWrapper.publicInstall ? '' : 'dropdown-submenu pull-left'}">
                                                <ui:fragment rendered="#{!settingsWrapper.publicInstall}">
                                                    <a tabindex="-1" href="#">#{bundle['dataset.editBtn.itemLabel.permissions']}</a>
                                                    <ul class="dropdown-menu">
                                                        <li>
                                                            <h:link id="manageDatasetPermissions" styleClass="ui-commandlink ui-widget" outcome="permissions-manage">
                                                                <h:outputText value="#{bundle['dataset']}" />
                                                                <f:param name="id" value="#{DatasetPage.dataset.id}" />
                                                            </h:link>
                                                        </li>
                                                        <li>
                                                            <h:link id="manageFilePermissions" styleClass="ui-commandlink ui-widget" outcome="permissions-manage-files">
                                                                <h:outputText value="#{bundle['file']}" />
                                                                <f:param name="id" value="#{DatasetPage.dataset.id}" />
                                                            </h:link>
                                                        </li>
                                                    </ul>
                                                </ui:fragment>                                            
                                                <h:link id="managePermissions" rendered="#{settingsWrapper.publicInstall}"
                                                        styleClass="ui-commandlink ui-widget" outcome="permissions-manage">
                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.permissions']}" />
                                                    <f:param name="id" value="#{DatasetPage.dataset.id}" />
                                                </h:link>
                                            </li>
                                            <li>
                                                <p:commandLink id="privateUrl" oncomplete="PF('privateUrlConfirmation').show()" action="#{DatasetPage.initPrivateUrlPopUp()}" update="privateUrlPanel">
                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.privateUrl']}" />
                                                </p:commandLink>
                                            </li>
                                        </ui:fragment>
                                        <li>
                                            <h:outputLink value="/dataset-widgets.xhtml?datasetId=#{DatasetPage.dataset.id}">
                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.thumbnailsAndWidgets']}"/>
                                            </h:outputLink>
                                        </li>
                                        <ui:fragment rendered="#{!DatasetPage.dataset.released and DatasetPage.dataset.latestVersion.versionState=='DRAFT' and permissionsWrapper.canIssueDeleteDatasetCommand(DatasetPage.dataset)}">
                                            <li class="divider"></li>
                                            <li>
                                                <p:commandLink id="deleteDataset" onclick="PF('deleteConfirmation').show()">
                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.deleteDataset']}" />
                                                </p:commandLink>
                                            </li>
                                        </ui:fragment>
                                        <ui:fragment rendered="#{DatasetPage.dataset.released and DatasetPage.dataset.latestVersion.versionState=='DRAFT' and permissionsWrapper.canIssueDeleteDatasetCommand(DatasetPage.dataset)}">
                                            <li class="divider"></li>
                                            <li>
                                                <p:commandLink id="deleteVersion" onclick="PF('deleteVersionConfirmation').show()">
                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.deleteDraft']}" />
                                                </p:commandLink>
                                            </li>
                                        </ui:fragment>
                                        <ui:fragment rendered="#{DatasetPage.dataset.released and DatasetPage.existReleasedVersion and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}">
                                            <li class="divider"></li>
                                            <li>
                                                <p:commandLink id="deaccessionDatasetLink" 
                                                               action="#{DatasetPage.clickDeaccessionDataset}"
                                                               oncomplete="PF('deaccessionBlock').show();bind_bsui_components();"
                                                               update="deaccessionBlock">
                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.deaccession']}" />
                                                </p:commandLink>
                                            </li>
                                        </ui:fragment>
                                    </ul>
                                </ui:fragment>
                                <!-- END: Edit Button -->
                                <!-- END: Edit/Link/Publish Button Group -->
                            </div>
                            
                            <!-- Contact/Share Button Group -->
                            <!--<div class="btn-group pull-right" id="datasetButtonBar" role="group">
                                <p:commandLink class="text-button btn-contact bootstrap-button-tooltip" title="#{bundle['dataset.email.datasetContactBtn']}"
                                               update=":contactDialog" oncomplete="PF('contactForm').show()" actionListener="#{sendFeedbackDialog.initUserInput}">
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{DatasetPage.dataset}"/>
                                    <span class="glyphicon glyphicon-envelope"/> #{bundle['contact.contact']}
                                </p:commandLink>
                                <p:commandLink styleClass="text-button btn-share bootstrap-button-tooltip" rendered="#{!DatasetPage.workingVersion.deaccessioned}"
                                               title="#{bundle['dataset.share.datasetShare']}"
                                               oncomplete="PF('shareDialog').show();sharrre();">
                                    <span class="glyphicon glyphicon-share"/> #{bundle['share']}
                                </p:commandLink>
                            </div>-->
                            <p:dialog id="shareDialog" header="#{bundle['dataset.share.datasetShare']}" widgetVar="shareDialog" modal="true" rendered="#{!DatasetPage.workingVersion.deaccessioned}">
                                <p class="help-block">#{bundle['dataset.share.datasetShare.tip']}</p>

                                <div id="sharrre-widget" data-url="#{DatasetPage.dataverseSiteUrl}/dataset.xhtml?persistentId=#{dataset.globalId}" data-text="#{bundle['dataset.share.datasetShare.shareText']}"></div>

                                <div class="button-block">
                                    <button class="btn btn-default" onclick="PF('shareDialog').hide()" type="button">
                                        #{bundle.close}
                                    </button>
                                </div>
                            </p:dialog>
                            <!-- END: Contact/Share Button Group -->
                        </div>
                        
                        <div id="datasetVersionBlock" class="col-sm-12">
                            <div id="title-block" class="row margin-bottom-half" jsf:rendered="#{!empty DatasetPage.datasetVersionUI.title.value}">
                                <div class="col-xs-1 vcenter title-preview-icon-block">
                                    <img src="#{DatasetPage.thumbnailString}" jsf:rendered="#{!empty DatasetPage.thumbnailString}" alt="#{DatasetPage.datasetVersionUI.title.value}"/>
                                    <span class="icon-dataset" jsf:rendered="#{empty DatasetPage.thumbnailString}"/>
                                </div>
                                <div class="col-xs-11 vcenter">
                                    <span id="title">#{DatasetPage.datasetVersionUI.title.value}</span>
                                    
                                    <div id="title-label-block" class="margin-top-half">
                                        <h:outputText value="#{bundle['dataset.versionUI.draft']}" styleClass="label label-primary" rendered="#{DatasetPage.workingVersion.draft}"/>
                                        <h:outputText value="#{bundle['dataset.versionUI.inReview']}" styleClass="label label-success" rendered="#{DatasetPage.workingVersion.inReview}"/>
                                        <h:outputText value="#{bundle['dataset.versionUI.unpublished']}" styleClass="label label-warning" rendered="#{!DatasetPage.dataset.released}"/>
                                        <h:outputText value="#{bundle['dataset.versionUI.deaccessioned']}" styleClass="label label-danger" rendered="#{DatasetPage.workingVersion.deaccessioned}"/>
                                        <!-- DATASET VERSION NUMBER -->
                                        <h:outputText styleClass="label label-default" rendered="#{DatasetPage.workingVersion.released and !(DatasetPage.workingVersion.draft or DatasetPage.workingVersion.inReview or DatasetPage.workingVersion.deaccessioned)}"
                                                      value="#{bundle['file.DatasetVersion']} #{DatasetPage.workingVersion.versionNumber}.#{DatasetPage.workingVersion.minorVersionNumber}" /> 
                                        <h:outputText styleClass="label label-default" rendered="#{!DatasetPage.workingVersion.released and !(DatasetPage.workingVersion.draft or DatasetPage.workingVersion.inReview or DatasetPage.workingVersion.deaccessioned)}"
                                                      value="#{bundle['file.DatasetVersion']} #{DatasetPage.workingVersion.versionState}"/>
                                    </div>
                                </div>
                            </div>
                            
                            <!--<div class="row">
                                &lt;!&ndash; CITATION BLOCK &ndash;&gt;
                                <ui:fragment rendered="#{!empty DatasetPage.displayCitation}">
                                    <ui:include src="dataset-citation.xhtml">
                                        <ui:param name="datasetPage" value="true"/>
                                    </ui:include>
                                </ui:fragment>
                                &lt;!&ndash; END: CITATION BLOCK &ndash;&gt;
                                <div id="deaccession-reason-block" class="bg-danger" jsf:rendered="#{DatasetPage.workingVersion.deaccessioned}">
                                    <h5 class="margin-top-half">#{bundle['dataset.deaccession.reason']}</h5>
                                    <p>#{DatasetPage.workingVersion.versionNote}</p>
                                    <ui:fragment rendered="#{!empty DatasetPage.workingVersion.archiveNote}">
                                        <p>#{bundle['dataset.beAccessedAt']} <a href="#{DatasetPage.workingVersion.archiveNote}" target="_blank">#{DatasetPage.workingVersion.archiveNote}</a></p>
                                    </ui:fragment>
                                </div>
                                
                                &lt;!&ndash; Metrics &ndash;&gt;
                                <div id="metrics-block" class="col-sm-3" jsf:rendered="#{!(settingsWrapper.rsyncDownload or DatasetPage.workingVersion.deaccessioned)}">
                                    <div id="metrics-heading">
                                        #{bundle['metrics.dataset.title']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top" 
                                                data-original-title="#{settingsWrapper.makeDataCountEnabled ? bundle['metrics.dataset.tip.makedatacount'] : bundle['metrics.dataset.tip.default']}"></span>
                                    </div>
                                    <div id="metrics-body">
                                        &lt;!&ndash; Classic downloads &ndash;&gt;
                                        <div class="metrics-count-block" jsf:rendered="#{!settingsWrapper.makeDataCountEnabled}">
                                            <h:outputFormat value="{0} #{bundle['metrics.downloads']}">
                                                <f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDatasetId(DatasetPage.dataset.id)}"/>
                                            </h:outputFormat>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                    data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.default.tip']}"></span>
                                        </div>
                                        &lt;!&ndash; Make Data Count views &ndash;&gt;
                                        <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled}">
                                            <h:outputFormat value="{0} #{bundle['metrics.views']}">
                                                <f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getViewsTotal()}"/>
                                            </h:outputFormat>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                    data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.views.tip']}"></span>
                                        </div>
                                        &lt;!&ndash; Make Data Count downloads &ndash;&gt;
                                        <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled}">
                                            <h:outputFormat value="{0} #{bundle['metrics.downloads']}">
                                                <f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getDownloadsTotal()}"/>
                                            </h:outputFormat>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                    data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.makedatacount.tip']}"></span>
                                        </div>
                                        &lt;!&ndash; Make Data Count citations (DOIs only, not Handles) &ndash;&gt;
                                        <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled and settingsWrapper.doiInstallation}">
                                            <p:commandLink oncomplete="PF('citationsDialog').show();">
                                                <h:outputFormat value="{0} #{bundle['metrics.citations']}">
                                                    <f:param value="#{fn:length(datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset))}"/>
                                                </h:outputFormat>
                                            </p:commandLink>
                                            
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                    data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.citations.tip']}"></span>
                                        
                                            <p:dialog id="citationsDialog" styleClass="smallPopUp" header="#{bundle['metrics.citations.dialog.header']}" widgetVar="citationsDialog" modal="true">
                                                <p class="help-block">
                                                    <h:outputFormat value="#{bundle['metrics.citations.dialog.help']}" escape="false">
                                                        <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                                        <f:param value="#{systemConfig.guidesVersion}"/>
                                                    </h:outputFormat>
                                                </p>
                                                
                                                <div id="citations-list-block">
                                                    <div jsf:rendered="#{empty datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}">
                                                        #{bundle['metrics.citations.dialog.empty']}
                                                    </div>
                                                    <ui:fragment rendered="#{!empty datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}">
                                                        <ul>
                                                            <ui:repeat value="#{datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}" var="citation">
                                                                <li><a href="#{citation.citedByUrl}" target="_blank">#{citation.citedByUrl}</a></li>
                                                            </ui:repeat>
                                                        </ul>
                                                    </ui:fragment>
                                                </div>

                                                <div class="button-block">
                                                    <button class="btn btn-default" onclick="PF('citationsDialog').hide()" type="button">
                                                        #{bundle.close}
                                                    </button>
                                                </div>
                                            </p:dialog>
                                        </div>
                                    </div>
                                </div>
                                &lt;!&ndash; END: Metrics &ndash;&gt;
                            </div>-->
                            
                            <!-- BEGIN: DATASET SUMMARY -->
                            <div id="dataset-summary-metadata" class="row" style="background-color:lightgoldenrodyellow;background:none;"
                                 jsf:rendered="#{!widgetWrapper.widgetView and !DatasetPage.workingVersion.deaccessioned and 
                                                   ( !empty DatasetPage.datasetVersionUI.descriptionDisplay
                                                 or !empty DatasetPage.datasetVersionUI.keywordDisplay
                                                 or !empty DatasetPage.datasetVersionUI.subject.value
                                                 or !empty DatasetPage.datasetVersionUI.relPublicationCitation
                                                 or !empty DatasetPage.datasetVersionUI.notes.value  ) and !empty DatasetPage.datasetSummaryFields }">
                                <div class="col-sm-9 metadata-container">
                                    <ui:repeat value="#{DatasetPage.datasetSummaryFields}" var="dsf">
                                        
                                        <div id="keywords" class="form-group" jsf:rendered="#{!empty DatasetPage.datasetVersionUI.keywordDisplay and dsf.datasetFieldType.id==DatasetPage.datasetVersionUI.keyword.datasetFieldType.id}">
                                            <label class="col-sm-3 control-label">
                                                #{bundle['dataset.keywordDisplay.title']}
                                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{DatasetPage.datasetVersionUI.keyword.datasetFieldType.localeDescription}"></span>
                                            </label>
                                            <div class="col-sm-9">#{DatasetPage.datasetVersionUI.keywordDisplay}</div>
                                        </div>
                                        <div id="publication" class="form-group" jsf:rendered="#{!empty DatasetPage.datasetVersionUI.relPublicationCitation and dsf.datasetFieldType.name=='publication'}">
                                            <label class="col-sm-3 control-label">
                                                #{DatasetPage.datasetVersionUI.datasetRelPublications.get(0).title}
                                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{DatasetPage.datasetVersionUI.datasetRelPublications.get(0).description}"></span>
                                            </label>
                                            <div class="col-sm-9">
                                                <h:outputText value="#{MarkupChecker:sanitizeBasicHTML(DatasetPage.datasetVersionUI.relPublicationCitation)}" escape="false"/>
                                                <a href="#{DatasetPage.datasetVersionUI.relPublicationUrl}" title="#{DatasetPage.datasetVersionUI.relPublicationUrl}" target="_blank">#{DatasetPage.datasetVersionUI.relPublicationId}</a>
                                            </div>
                                        </div>
                                     
                                        <div class="form-group" jsf:rendered="#{dsf.datasetFieldType.name!='publication' and dsf.datasetFieldType.name!='keyword'  }">
                                            <label for="metadata_#{dsf.datasetFieldType.name}" class="col-sm-3 control-label">
                                                #{dsf.datasetFieldType.localeTitle}
                                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{dsf.datasetFieldType.localeDescription}"></span>
                                            </label>
                                            <!-- Primitive datasetFields -->
                                            <div class="col-sm-9" jsf:rendered="#{dsf.datasetFieldType.primitive}">
                                                <h:outputText value="#{dsf.displayValue}" rendered="#{!dsf.datasetFieldType.allowMultiples}"
                                                              escape="#{dsf.datasetFieldType.isEscapeOutputText()}"/>
                                                <ui:repeat value="#{dsf.values}" var="value" varStatus="loop" rendered="#{dsf.datasetFieldType.allowMultiples}">
                                                    <h:outputText value="#{loop.first?'':'; '}#{ value }"
                                                                  escape="#{dsf.datasetFieldType.isEscapeOutputText()}"/>
                                                </ui:repeat>
                                            </div>
                                            <!-- Compound datasetFields -->
                                            <div class="col-sm-9" jsf:rendered="#{dsf.datasetFieldType.compound}">
                                                <ui:fragment rendered="#{dsf.datasetFieldType.name == 'datasetContact'}">
                                                    <p class="help-block">
                                                        <h:outputText value="#{bundle['dataset.contact.tip']}"/>
                                                    </p>
                                                </ui:fragment>
                                                <ui:repeat value="#{dsf.datasetFieldCompoundValues}" var="compoundValue">
                                                    <div>
                                                    <ui:repeat value="#{compoundValue.displayValueMap.entrySet().toArray()}" var="cvPart" varStatus="partStatus">
                                                        <h:outputText value="#{dsf.datasetFieldType.displayFormat} " rendered="${!partStatus.first}"/>
                                                        <h:outputText value="#{cvPart.value}"
                                                                      escape="#{cvPart.key.datasetFieldType.isEscapeOutputText()}"/>
                                                    </ui:repeat>
                                                    </div>
                                                </ui:repeat>
                                            </div>
                                        </div>
                                    </ui:repeat>
                                </div>
                                <!-- Metrics -->
                                <div id="metrics-block" class="col-sm-3" jsf:rendered="#{!(settingsWrapper.rsyncDownload or DatasetPage.workingVersion.deaccessioned)}">
                                    <div id="metrics-heading">
                                        #{bundle['metrics.dataset.title']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top"
                                              data-original-title="#{settingsWrapper.makeDataCountEnabled ? bundle['metrics.dataset.tip.makedatacount'] : bundle['metrics.dataset.tip.default']}"></span>
                                    </div>
                                    <div id="metrics-body">
                                        <!-- Classic downloads -->
                                        <div class="metrics-count-block" jsf:rendered="#{!settingsWrapper.makeDataCountEnabled}">
                                            <h:outputFormat value="{0} #{bundle['metrics.downloads']}">
                                                <f:param value="#{guestbookResponseServiceBean.getCountGuestbookResponsesByDatasetId(DatasetPage.dataset.id)}"/>
                                            </h:outputFormat>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.default.tip']}"></span>
                                        </div>
                                        <!-- Make Data Count views -->
                                        <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled}">
                                            <h:outputFormat value="{0} #{bundle['metrics.views']}">
                                                <f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getViewsTotal()}"/>
                                            </h:outputFormat>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.views.tip']}"></span>
                                        </div>
                                        <!-- Make Data Count downloads -->
                                        <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled}">
                                            <h:outputFormat value="{0} #{bundle['metrics.downloads']}">
                                                <f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getDownloadsTotal()}"/>
                                            </h:outputFormat>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.makedatacount.tip']}"></span>
                                        </div>
                                        <!-- Make Data Count citations (DOIs only, not Handles) -->
                                        <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountEnabled and settingsWrapper.doiInstallation}">
                                            <p:commandLink oncomplete="PF('citationsDialog').show();">
                                                <h:outputFormat value="{0} #{bundle['metrics.citations']}">
                                                    <f:param value="#{fn:length(datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset))}"/>
                                                </h:outputFormat>
                                            </p:commandLink>

                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.citations.tip']}"></span>

                                            <p:dialog id="citationsDialog" styleClass="smallPopUp" header="#{bundle['metrics.citations.dialog.header']}" widgetVar="citationsDialog" modal="true">
                                                <p class="help-block">
                                                    <h:outputFormat value="#{bundle['metrics.citations.dialog.help']}" escape="false">
                                                        <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                                        <f:param value="#{systemConfig.guidesVersion}"/>
                                                    </h:outputFormat>
                                                </p>

                                                <div id="citations-list-block">
                                                    <div jsf:rendered="#{empty datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}">
                                                        #{bundle['metrics.citations.dialog.empty']}
                                                    </div>
                                                    <ui:fragment rendered="#{!empty datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}">
                                                        <ul>
                                                            <ui:repeat value="#{datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}" var="citation">
                                                                <li><a href="#{citation.citedByUrl}" target="_blank">#{citation.citedByUrl}</a></li>
                                                            </ui:repeat>
                                                        </ul>
                                                    </ui:fragment>
                                                </div>

                                                <div class="button-block">
                                                    <button class="btn btn-default" onclick="PF('citationsDialog').hide()" type="button">
                                                        #{bundle.close}
                                                    </button>
                                                </div>
                                            </p:dialog>
                                        </div>
                                    </div>
                                </div>
                                <!-- END: Metrics -->
                            </div>
                            <!-- END: DATASET SUMMARY -->
                        </div>
                    </div>
                    </p:fragment>
                    <!-- END View editMode -->

                    <!-- Create/Edit editMode -->
                    <ui:fragment rendered="#{DatasetPage.editMode == 'METADATA' or DatasetPage.editMode == 'CREATE'}">
                        <p:focus context="datasetForm"/>
                        <div class="form-group">
                            <label for="select_HostDataverse" class="col-sm-2 control-label">
                                #{bundle.hostDataverse}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.host.title']}"></span>
                            </label>
                            <div class="col-sm-10">
                                <h:outputText styleClass="highlightBold" value="#{DatasetPage.dataset.owner.name}"/>
                                <h:inputHidden value="#{DatasetPage.ownerId}" id="select_HostDataverse" />
                                <ui:remove><!-- removed for beta -->
                                    <p:selectOneMenu id="select_HostDataverse" value="#{DatasetPage.ownerId}" filter="true" filterMatchMode="startsWith" effect="none">
                                        <f:selectItems value="#{dataverseServiceBean.findAll()}" var="dv" itemLabel="#{dv.name}" itemValue="#{dv.id}"/>
                                    </p:selectOneMenu>
                                </ui:remove>
                            </div>
                        </div>
                        <div class="form-group" jsf:rendered="#{!empty DatasetPage.dataverseTemplates and DatasetPage.editMode == 'CREATE'}">
                            <label for="select_DatasetTemplate" class="col-sm-2 control-label">
                                #{bundle['dataset.manageTemplates.tab.action.btn.view.dialog.datasetTemplate']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.manageTemplates.tab.action.btn.view.dialog.datasetTemplate.title']}"></span>
                            </label>
                            <div class="col-sm-6">
                                <p class="help-block">
                                    #{bundle['dataset.template.tip']}
                                </p>
                                <p:selectOneMenu value="#{DatasetPage.selectedTemplate}" onchange="updateTemplate()"
                                                 converter="templateConverter" id="select_DatasetTemplate" styleClass="form-control"
                                                 valueChangeListener="#{DatasetPage.updateSelectedTemplate}"
                                                 style="width:auto !important; max-width:100%; min-width:200px;">
                                    <f:selectItem itemLabel="#{bundle['dataset.noTemplate.label']}" itemValue="#{null}" />
                                    <f:selectItems value="#{DatasetPage.dataverseTemplates}"
                                                   var="template" itemLabel="#{template.name}" itemValue="#{template}"/>
                                </p:selectOneMenu>
                                <p:commandButton value="#{bundle['file.dataFilesTab.button.direct']}" id="updateTemplate"
                                                 style="display:none"
                                                 update=":datasetForm,accessPopup"
                                                 action="#{DatasetPage.handleChangeButton}" oncomplete="javascript:bind_bsui_components();">
                                </p:commandButton>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <span class="glyphicon glyphicon-asterisk text-danger"/> <h:outputText value="#{bundle['dataset.asterisk.tip']}"/>
                            </div>
                        </div>
                    </ui:fragment>
                    <ui:fragment rendered="#{DatasetPage.editMode == 'CREATE'}">
                        <ui:include src="metadataFragment.xhtml">
                            <ui:param name="datasetPage" value="true"/>
                            <ui:param name="editMode" value="#{!empty DatasetPage.editMode ? DatasetPage.editMode : ''}"/>
                            <ui:param name="metadataBlocks" value="#{!empty DatasetPage.editMode ? DatasetPage.datasetVersionUI.metadataBlocksForEdit.entrySet().toArray(): DatasetPage.datasetVersionUI.metadataBlocksForView.entrySet().toArray()}"/>
                            <ui:param name="publicationDate" value="#{DatasetPage.dataset.publicationDateFormattedYYYYMMDD}"/>
                            <ui:param name="globalId" value="#{DatasetPage.dataset.globalIdString}"/>
                        </ui:include>
                    </ui:fragment>
                    <!-- END Create/Edit editMode -->

                    <!-- Edit editMode -->
                    <div class="button-block form-top" jsf:rendered="#{DatasetPage.editMode == 'METADATA' or DatasetPage.editMode == 'LICENSE'}">
                        <p:commandButton id="saveTop" styleClass="btn btn-default" value="#{bundle.saveChanges}" onclick="checkNewlyRestricted();PF('blockDatasetForm').show();"/>
                        <p:commandButton id="cancelTop" styleClass="btn btn-link" value="#{bundle.cancel}" action="#{DatasetPage.cancel}" process="@this" update="@form" oncomplete="javascript:bind_bsui_components();">
                            <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="#{DatasetPage.editMode == 'METADATA' ? 1 : DatasetPage.selectedTabIndex}"/>
                        </p:commandButton>
                    </div>
                    <!-- END Header / Button Panel -->
                    <!-- View/Tabs infoMode -->
                    <!-- Tabs -->
                    <div id="contentTabs" jsf:rendered="#{DatasetPage.editMode != 'INFO'}">

                        <p:fragment id="pageRefreshFragment"> <!-- rendered="_{empty DatasetPage.editMode}" -->
                            <h:inputHidden value="#{DatasetPage.lockedForAnyReason}" id="datasetLockedForAnyReasonVariable" />
                            <h:inputHidden value="#{DatasetPage.stateChanged}" id="datasetStateChangedVariable" />

                            <p:remoteCommand name="refreshAllLocksCommand" process="@this" update=":#{p:resolveClientId('datasetForm:pageRefreshFragment', view)}" actionListener="#{DatasetPage.refreshAllLocks()}"/>
                            <p:remoteCommand name="refreshAllCommand" process="@this" update=":datasetForm:topDatasetBlockFragment,:datasetForm:tabView:filesTable,:messagePanel" action="#{DatasetPage.refresh()}"/>

                            <!-- see the comment in the javascript below that explains what this button is for -->
                            <p:commandButton id="refreshButton" process="@this" widgetVar="refreshButton" update=":datasetForm:topDatasetBlockFragment,:datasetForm:tabView:filesTable" style="display:none"/>
                            
                            <script>
                                //<![CDATA[
                                $(this).ready(function () {
                                    refreshIfStillLocked();
                                });

                                function refreshIfStillLocked() {
                                    if ($('input[id$="datasetLockedForAnyReasonVariable"]').val() === 'true') {
                                        // if dataset is locked, instruct the page to
                                        // wait and check again:
                                        waitAndCheckLockAgain();
                                    } else {
                                        // if not locked, has it just been unlocked?
                                        if ($('input[id$="datasetStateChangedVariable"]').val() === 'true') {
                                            // For whatever unknown PrimeFaces reason
                                            // the page needs to be refreshed twice, for all
                                            // the pull down menus to update properly:
                                            refreshAllCommand();
                                            // You can't just run 2 refreshAllCommand()s in a row
                                            // either; because the command has an "update=@all" on it,
                                            // so I guess if you try to execute the 2nd one right after
                                            // the first one, this fragment is still going to be loading -
                                            // so there would not yet be a command to run! (it needs to
                                            // be rendered, before you can execute it, that is)
                                            setTimeout(function () {
                                                // this button doesn't do anything, but it has an update="@all"
                                                // attribute:
                                                $('button[id$="refreshButton"]').trigger('click');
                                                //refreshAllCommand();
                                            }, 1500);
                                        }
                                    }
                                }

                                function waitAndCheckLockAgain() {
                                    setTimeout(function () {
                                        // refresh the lock in the
                                        // backing bean; i.e., check, if the ingest has
                                        // already completed in the background:
                                        //$('button[id$="refreshButton"]').trigger('click');
                                        //refreshLockCommand();
                                        refreshAllLocksCommand();
                                    }, 10000);
                                }
                                //]]>
                            </script>
                        </p:fragment>

                        <ui:fragment id="uploadFilesOnCreateTab" rendered="#{!DatasetPage.workingVersion.deaccessioned and                          
                                                                             (DatasetPage.editMode == 'CREATE')}">

                                <ui:include src="editFilesFragment.xhtml">
                                    <ui:param name="datasetPage" value="true"/>
                                    <ui:param name="editDatafilesPage" value="false"/>                                   
                                    <ui:param name="dataverse" value="#{DatasetPage.dataset.owner}"/>
                                    <ui:param name="dataset" value="#{DatasetPage.dataset}"/>
                                    <ui:param name="version" value="#{DatasetPage.workingVersion}"/>
                                    <ui:param name="createDataset" value="true"/>
                                </ui:include>

                        </ui:fragment>

                        <p:tabView id="tabView" widgetVar="content" activeIndex="#{DatasetPage.selectedTabIndex}"
                                   rendered="#{empty DatasetPage.editMode or (DatasetPage.editMode == 'METADATA' or DatasetPage.editMode == 'LICENSE')}">
                            <p:ajax event="tabChange" listener="#{DatasetPage.tabChanged}" oncomplete="bind_bsui_components();" update="@this" />
                            <p:tab id="dataFilesTab" title="#{bundle.files}" rendered="#{(!DatasetPage.workingVersion.deaccessioned or 
                                                              (DatasetPage.workingVersion.deaccessioned and DatasetPage.canUpdateDataset()))  and
                                                              (empty DatasetPage.editMode)}">
                                <ui:include src="filesFragment.xhtml">
                                    <ui:param name="fileDownloadHelper" value="#{DatasetPage.fileDownloadHelper}"/>
                                </ui:include>
                            </p:tab>

                            <!-- 4.2.1: the 3 tabs below - metadata, terms and versions: these account for ~100 queries total -->
                            <!-- a lot of these however, are repeated queries on AuthenticatedUser and RoleAssignment; once these are optimized, the tabs will become very cheap. -->
                            <p:tab id="metadataMapTab" title="#{bundle['file.dataFilesTab.metadata.header']}"
                                        rendered="#{(!DatasetPage.workingVersion.deaccessioned or (DatasetPage.workingVersion.deaccessioned and DatasetPage.canUpdateDataset())) 
                                             and (empty DatasetPage.editMode or DatasetPage.editMode == 'METADATA')}">

                                <div class="button-block tab-header margin-bottom text-right" jsf:rendered="#{empty DatasetPage.editMode}">
                                    <p:commandLink styleClass="btn btn-default btn-access" actionListener="#{DatasetPage.edit('METADATA')}" update="@form,:messagePanel" oncomplete="javascript:bind_bsui_components();" 
                                                   disabled="#{DatasetPage.locked}" rendered="#{!widgetWrapper.widgetView and (DatasetPage.sessionUserAuthenticated and empty DatasetPage.editMode and !widgetWrapper.widgetView
                                                               and DatasetPage.canUpdateDataset() and !DatasetPage.dataset.deaccessioned)}">
                                        <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0"/>
                                        <span class="glyphicon glyphicon-pencil"/> #{bundle['file.dataFilesTab.metadata.addBtn']}
                                    </p:commandLink>
                                    <div class="btn-group" jsf:rendered="#{DatasetPage.dataset.released and !DatasetPage.dataset.deaccessioned}">
                                        <button class="btn btn-default btn-export dropdown-toggle" type="button" data-toggle="dropdown">
                                            <span class="glyphicon glyphicon-export"/> #{bundle['dataset.exportBtn']} <span class="caret"/></button>
                                        <ul class="dropdown-menu" role="menu">
                                            <ui:repeat var="exporter" value="#{DatasetPage.exporters}">
                                                <li>
                                                    <h:outputLink value="#{exporter[1]}" target="_blank">
                                                        <h:outputText value="#{exporter[0]}"/>
                                                    </h:outputLink>
                                                </li>  
                                            </ui:repeat>
                                        </ul>
                                    </div>
                                </div>
                                <ui:include src="metadataFragment.xhtml">
                                    <ui:param name="datasetPage" value="true"/>
                                    <ui:param name="editMode" value="#{!empty DatasetPage.editMode ? DatasetPage.editMode : ''}"/>
                                    <ui:param name="metadataBlocks" value="#{!empty DatasetPage.editMode ? DatasetPage.datasetVersionUI.metadataBlocksForEdit.entrySet().toArray(): DatasetPage.datasetVersionUI.metadataBlocksForView.entrySet().toArray()}"/>
                                    <ui:param name="publicationDate" value="#{DatasetPage.dataset.publicationDate != null ? DatasetPage.dataset.publicationDateFormattedYYYYMMDD : ''}"/>
                                    <ui:param name="globalId" value="#{DatasetPage.dataset.globalIdString}"/>
                                    <ui:param name="altPID" value="#{DatasetPage.dataset.alternativePersistentIdentifier}"/>
                                </ui:include>
                            </p:tab>

                            <!-- 4.2.1: see comment above -->
                            <p:tab id="termsTab" title="#{bundle['file.dataFilesTab.terms.header']}"
                                   rendered="#{!DatasetPage.workingVersion.deaccessioned and (empty DatasetPage.editMode or DatasetPage.editMode == 'LICENSE')}">
                                <ui:include src="dataset-license-terms.xhtml">
                                    <ui:param name="editMode" value="#{!empty DatasetPage.editMode ? 'LICENSE': ''}"/>
                                    <ui:param name="termsOfUseAndAccess" value="#{DatasetPage.workingVersion.termsOfUseAndAccess}"/>
                                    <ui:param name="datasetPage" value="true"/>
                                </ui:include>
                            </p:tab>
                            <!-- 4.2.1: see above -->
                            <p:tab id="versionsTab" title="#{bundle['file.dataFilesTab.versions']}" rendered="#{empty DatasetPage.editMode}">
                                <ui:include src="dataset-versions.xhtml"></ui:include>
                            </p:tab>
                        </p:tabView>
                    </div>
                    <!-- END View/Tabs infoMode -->

                    <!-- Create Metadata Tip -->
                    <div class="alert alert-info margin-top" jsf:rendered="#{DatasetPage.editMode == 'CREATE'}">
                        #{bundle['file.metadataTip']}
                    </div>

                    <!-- Create/Save Dataset Button Panel -->
                    <div class="button-block" jsf:rendered="#{!empty DatasetPage.editMode}">
                        <p:commandButton id="save" styleClass="btn btn-default" value="#{DatasetPage.editMode == 'CREATE' ? bundle['file.addBtn'] : bundle.saveChanges}" onclick="checkNewlyRestricted();PF('blockDatasetForm').show();"/>
                        <p:commandButton id="cancel" styleClass="btn btn-link" value="#{bundle.cancel}" action="#{DatasetPage.cancel}" process="@this" update="@form" rendered="#{DatasetPage.editMode != 'CREATE'}" oncomplete="javascript:bind_bsui_components();">
                            <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="#{DatasetPage.editMode == 'METADATA' ? 1 : DatasetPage.selectedTabIndex}"/>
                        </p:commandButton>
                        <p:button id="cancelCreate" styleClass="btn btn-link" value="#{bundle.cancel}" outcome="/dataverse.xhtml?alias=#{DatasetPage.dataset.owner.alias}" rendered="#{DatasetPage.editMode == 'CREATE'}"/>
                        <p:commandButton value="Direct" id="datasetSave"
                                         style="display:none"
                                         update=":datasetForm,:messagePanel"
                                         oncomplete="javascript:bind_bsui_components();$(document).scrollTop(0);"
                                         action="#{DatasetPage.save}"/>
                    </div>
                    <!-- END: Create/Save Dataset Button Panel -->

                    <p:blockUI block="datasetForm" widgetVar="blockDatasetForm"/>

                    <!-- Popups -->
                    <p:dialog id="downloadInvalid" styleClass="smallPopUp" header="#{bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadInvalid" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noValidSelectedFilesForDownload']}</p>
                        <ui:fragment rendered="#{DatasetPage.dataset.fileAccessRequest}">
                            <p class="help-block">#{bundle['dataset.requestAccessToRestrictedFiles']}</p>
                        </ui:fragment>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('downloadInvalid').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="downloadMixed" styleClass="smallPopUp" header="#{bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadMixed" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.mixedSelectedFilesForDownload']}</p>
                        <table>
                            <ui:repeat var="resFile" value="#{DatasetPage.selectedNonDownloadableFiles}" >
                                <tr>
                                    <td>#{resFile.label}</td>
                                </tr>
                            </ui:repeat>
                        </table>
                        <div class="button-block">
                            <p class="help-block">#{bundle['dataset.downloadUnrestricted']}</p>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('downloadMixed').hide()" 
                                             rendered="#{!DatasetPage.downloadPopupRequired}"
                                             action="#{DatasetPage.startMultipleFileDownload()}"/>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('downloadMixed').hide()"
                                             rendered="#{DatasetPage.downloadPopupRequired and !settingsWrapper.rsyncDownload}"
                                             action="#{DatasetPage.openDownloadPopupForMultipleFileDownload()}" update="@form"/>
                            <button class="btn btn-link" onclick="PF('downloadMixed').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deleteConfirmation" styleClass="smallPopUp" header="#{bundle['file.deleteDialog.header']}" widgetVar="deleteConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteDialog.tip']}</p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('deleteConfirmation').hide()" action="#{DatasetPage.deleteDataset()}"/>
                            <button class="btn btn-link" onclick="PF('deleteConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deleteVersionConfirmation" styleClass="smallPopUp" header="#{bundle['file.deleteDraftDialog.header']}" widgetVar="deleteVersionConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteDraftDialog.tip']}</p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('deleteVersionConfirmation').hide()" action="#{DatasetPage.deleteDatasetVersion()}"/>
                            <button class="btn btn-link" onclick="PF('deleteVersionConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="privateUrlId" styleClass="smallPopUp" header="#{bundle['dataset.privateurl.header']}" widgetVar="privateUrlConfirmation" modal="true">
                        <p:fragment id="privateUrlPanel" rendered="#{DatasetPage.userCanCreatePrivateURL}">
                            <p class="help-block">
                                <h:outputFormat value="#{bundle['dataset.privateurl.tip']}" escape="false">
                                    <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                    <f:param value="#{systemConfig.guidesVersion}"/>
                                </h:outputFormat>
                            </p>
                            <div>
                                <div class="highlight" jsf:rendered="#{empty(DatasetPage.privateUrl)}">
                                    <p class="no-margin-bottom">#{bundle['dataset.privateurl.absent']}</p>
                                </div>
                                <div class="highlight" jsf:rendered="#{!empty(DatasetPage.privateUrl)}" onclick="if (event.target) {
                                            selectText(event.target);
                                        } else {
                                            selectText(this);
                                        }">
                                    <p class="text-success highlightBold" jsf:rendered="#{DatasetPage.privateUrlWasJustCreated}"><span class="glyphicon glyphicon glyphicon-ok"/> #{bundle['dataset.privateurl.createdSuccess']}</p>
                                    <ui:param name="privateUrlLink" value="#{DatasetPage.getPrivateUrlLink(DatasetPage.privateUrl)}" />
                                    <p class="no-margin-bottom">
                                        <span>#{privateUrlLink}</span>
                                    </p>
                                </div>
                            </div>
                            <div class="button-block">
                                <p:commandButton styleClass="btn btn-default" value="#{bundle['dataset.privateurl.createPrivateUrl']}" action="#{DatasetPage.createPrivateUrl()}" update="privateUrlPanel,:messagePanel" rendered="#{empty(DatasetPage.privateUrl)}"/>
                                <p:commandButton styleClass="btn btn-default" value="#{bundle['dataset.privateurl.disablePrivateUrl']}" action="#{DatasetPage.setPrivateUrlJustCreatedToFalse()}" onclick="PF('privateUrlConfirmation').hide();PF('disablePrivateUrlConfirmation').show()" rendered="#{!empty(DatasetPage.privateUrl)}" update="privateUrlPanel"/>
                                <button class="btn btn-link" onclick="PF('privateUrlConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                    #{bundle.close}
                                </button>
                            </div>
                        </p:fragment>
                        <p:fragment id="privateUrlPanelCannotCreate" rendered="#{!DatasetPage.userCanCreatePrivateURL}">
                            <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.privateurl.cannotCreate']}</p>
                            <div class="button-block">
                                <button class="btn btn-link" onclick="PF('privateUrlConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                    #{bundle.cancel}
                                </button>
                            </div>
                        </p:fragment>
                    </p:dialog>
                    <p:dialog id="disablePrivateUrlConfirmation" styleClass="smallPopUp" header="#{bundle['dataset.privateurl.header']}" widgetVar="disablePrivateUrlConfirmation" modal="true" closable="false">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.privateurl.disableConfirmationText']}</p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle['dataset.privateurl.disablePrivateUrlConfirm']}" action="#{DatasetPage.disablePrivateUrl()}" update="privateUrlPanel,:messagePanel" onclick="PF('disablePrivateUrlConfirmation').hide();"/>
                            <button class="btn btn-link" onclick="PF('disablePrivateUrlConfirmation').hide();PF('privateUrlConfirmation').show();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deleteSelectedFileConfirmation" styleClass="smallPopUp" header="#{bundle['file.deleteFileDialog.header']}" widgetVar="deleteSelectedFileConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteFileDialog.multiple.immediate']}</p>
                        <ui:fragment rendered="#{DatasetPage.dataset.released}">
                            <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteFileDialog.failed.tip']}</p>
                        </ui:fragment>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle['file.delete']}" onclick="PF('deleteSelectedFileConfirmation').hide()"
                                             action="#{DatasetPage.deleteFilesAndSave()}" />
                            <button class="btn btn-link" onclick="PF('deleteSelectedFileConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="computeInvalid" styleClass="smallPopUp" header="#{bundle['dataset.compute.computeBtn']}" widgetVar="computeInvalid" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.compute.computeBatchRestricted']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('computeInvalid').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:fragment>
                        <p:autoUpdate />
                        <p:outputPanel>
                            <p:dialog id="deaccessionBlock" rendered="#{DatasetPage.renderDeaccessionPopup}" header="#{bundle['dataset.editBtn.itemLabel.deaccession']}" widgetVar="deaccessionBlock" modal="true" visible="#{facesContext.validationFailed}">
                                <p:focus for="selectVersionChk"/>
                                <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deaccessionDialog.tip']}</p>
                                <div class="form-group" jsf:rendered="#{DatasetPage.releasedVersionTabList.size() > 1}">
                                    <label for="selectVersionChk">#{bundle['file.deaccessionDialog.reason.question1']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/></label>                           
                                    <p:selectManyCheckbox id="selectVersionChk" value="#{DatasetPage.selectedDeaccessionVersions}" converter="datasetVersionConverter"
                                                          layout="pageDirection" required="#{param['DO_DEACCESSION_VALIDATION']}" requiredMessage="#{bundle['file.deaccessionDialog.dialog.selectVersion.error']}" widgetVar="selectVersionChk">
                                        <f:selectItems value="#{DatasetPage.releasedVersionTabList}" var="versionTab" itemLabel="#{bundle['file.deaccessionDialog.version']} #{versionTab.versionNumber}.#{versionTab.minorVersionNumber}, #{versionTab.versionDate}"  itemValue="#{versionTab}" />
                                    </p:selectManyCheckbox>
                                    <p:message for="selectVersionChk"/>
                                </div>
                                <div class="form-group">
                                    <label for="reasonOptions">#{bundle['file.deaccessionDialog.reason.question2']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/></label>
                                    <p:selectOneMenu widgetVar="reasonOptions" id="reasonOptions" styleClass="form-control" value="#{DatasetPage.deaccessionReasonRadio}" required="#{param['DO_DEACCESSION_VALIDATION']}" 
                                                     binding="#{reasonRadio}" requiredMessage="#{bundle['file.deaccessionDialog.dialog.reason.error']}">
                                        <f:selectItem itemLabel="#{bundle.select}" itemValue="#{null}" noSelectionOption="true" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.identifiable']}" itemValue="1" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.beRetracted']}" itemValue="2" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.beTransferred']}" itemValue="3" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.IRB']}" itemValue="4" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.legalIssue']}" itemValue="5" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.notValid']}" itemValue="6" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.other']}" itemValue="7" />
                                    </p:selectOneMenu>
                                    <p:message for="reasonOptions"/>
                                </div>
                                <div class="form-group">
                                    <label for="reasonForDeaccession">
                                    #{bundle['file.deaccessionDialog.enterInfo']}
                                    </label>
                                    <p:inputTextarea id="reasonForDeaccession" styleClass="form-control"  autoResize="false" rows="2" cols="40"                                           
                                                     value="#{DatasetPage.deaccessionReasonText}" widgetVar="reasonForDeaccession" validator="#{DatasetPage.validateDeaccessionReason}"> 
                                        <f:attribute name="reasonRadio" value="#{reasonRadio}" />
                                    </p:inputTextarea>
                                    <p:message for="reasonForDeaccession"/>
                                </div>
                                <div class="form-group">
                                    <label for="forwardURLForDeaccession">
                                    #{bundle['file.deaccessionDialog.leaveURL']}
                                    </label>
                                    <p:inputText id="forwardURLForDeaccession" styleClass="form-control" value="#{DatasetPage.deaccessionForwardURLFor}" widgetVar="forwardURLForDeaccession"
                                                 validator="#{DatasetPage.validateForwardURL}"/>
                                    <p:message for="forwardURLForDeaccession"/>
                                    <p:watermark for="forwardURLForDeaccession" value="#{bundle['file.deaccessionDialog.leaveURL.watermark']}" id="watermark" />
                                </div>
                                <div class="button-block">
                                    <p:commandButton styleClass="btn btn-default" value="#{bundle.deaccession}"  
                                                     oncomplete="if (args &amp;&amp; !args.validationFailed) PF('deaccessionConfirmation').show();">
                                        <f:param name="DO_DEACCESSION_VALIDATION" value="true"/>
                                    </p:commandButton>
                                    <p:commandButton styleClass="btn btn-link" value="#{bundle.cancel}" action="#{DatasetPage.setRenderDeaccessionPopup(false)}" onclick="PF('deaccessionBlock').hide();PF('blockDatasetForm').hide();" immediate="true"/>
                                </div>
                            </p:dialog>
                        </p:outputPanel>
                    </p:fragment>
                    <p:dialog id="deaccessionConfirmation" header="#{bundle['dataset.editBtn.itemLabel.deaccession']}" widgetVar="deaccessionConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deaccessionDialog.deaccession.tip']}</p>
                        <div class="button-block">
                            <h:commandButton styleClass="btn btn-default" value="#{bundle.yes}" onclick="PF('deaccessionConfirmation').hide();
                                    PF('deaccessionBlock').hide()" action="#{DatasetPage.deaccessionVersions}" />
                            <button class="btn btn-link" onclick="PF('deaccessionConfirmation').hide();" type="button">
                                #{bundle.no}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deaccessionAllConfirmation" header="#{bundle['dataset.editBtn.itemLabel.deaccession']}" widgetVar="deaccessionAllConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deaccessionDialog.deaccessionDataset.tip']}</p>
                        <div class="button-block">
                            <h:commandButton styleClass="btn btn-default" value="#{bundle.yes}" 
                                            onclick="PF('deaccessionAllConfirmation').hide();PF('deaccessionBlock').hide();PF('blockDatasetForm').hide();" 
                                            action="#{DatasetPage.deaccessionVersions}"/>
                            <button class="btn btn-link" onclick="PF('deaccessionAllConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.no}
                            </button>
                        </div>
                    </p:dialog>
                    <p:inputText id="hiddenReasonInput" style="display:none" widgetVar="hiddenReasonInput"/>
                    <p:dialog id="compareTwo" header="#{bundle['file.viewDiffDialog.header']}" widgetVar="compareTwo" modal="true">
                        <p class="help-block"><span class="glyphicon glyphicon-exclamation-sign text-danger"/> <span class="text-danger">#{bundle['file.viewDiffDialog.dialog.warning']}</span></p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('compareTwo').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="detailsBlocks" styleClass="largePopUp" header="#{bundle['file.viewDiffDialog.header']}" widgetVar="detailsBlocks" modal="true">
                        <div id="version-title" class="margin-bottom-half">#{DatasetPage.datasetVersionDifference.newVersion.title}</div>
                        <div id="version-details-block" class=" clearfix margin-bottom-half">
                            <div class="pull-left">
                                &#160;
                            </div>
                            <div class="pull-left">
                                #{bundle['file.viewDiffDialog.version']}: #{DatasetPage.datasetVersionDifference.originalVersion.semanticVersion}<br/>
                                #{bundle['file.viewDiffDialog.lastUpdated']}: #{DatasetPage.datasetVersionDifference.originalVersion.localeLastUpdateTime}
                            </div>
                            <div class="pull-left">
                                #{bundle['file.viewDiffDialog.version']}: #{DatasetPage.datasetVersionDifference.newVersion.semanticVersion}<br/>
                                #{bundle['file.viewDiffDialog.lastUpdated']}: #{DatasetPage.datasetVersionDifference.newVersion.localeLastUpdateTime}
                            </div>
                        </div>
                        <ui:fragment rendered="#{!empty(DatasetPage.datasetVersionDifference.detailDataByBlock)}">
                            <ui:repeat value="#{DatasetPage.datasetVersionDifference.detailDataByBlock}" var="block">
                                <div class="panel panel-default">
                                    <div class="panel-heading text-info">
                                        <h:outputText value="#{block.get(0)[0].datasetFieldType.metadataBlock.localeDisplayName}" />
                                    </div>
                                    <p:dataTable id="byBlockInner" styleClass="dvnDifferanceTable" var="dsfArray" value="#{block}">
                                        <p:column styleClass="versionValue">
                                            <h:outputText value="#{dsfArray[0].datasetFieldType.localeTitle}" />
                                        </p:column>
                                        <p:column styleClass="versionDetails">
                                            <h:outputText rendered="#{dsfArray[0].datasetFieldType.primitive and !(dsfArray[0].isEmpty())}" value="#{dsfArray[0].displayValue}" />
                                            <h:outputText rendered="#{!dsfArray[0].datasetFieldType.primitive and !(dsfArray[0].isEmpty())}" value="#{dsfArray[0].compoundDisplayValue}" />
                                        </p:column>
                                        <p:column styleClass="versionDetails" >
                                            <h:outputText rendered="#{dsfArray[1].datasetFieldType.primitive and !(dsfArray[1].isEmpty())}" value="#{dsfArray[1].displayValue}" />
                                            <h:outputText rendered="#{!dsfArray[1].datasetFieldType.primitive and !(dsfArray[1].isEmpty())}" value="#{dsfArray[1].compoundDisplayValue}" />
                                        </p:column>
                                    </p:dataTable>
                                </div>
                            </ui:repeat>
                        </ui:fragment>
                        <div class="panel panel-default" jsf:rendered="#{!empty(DatasetPage.datasetVersionDifference.fileNote)}">
                            <ui:fragment rendered="#{!empty(DatasetPage.datasetVersionDifference.datasetFilesDiffList)}">
                            <div class="panel-heading text-info">
                                <h:outputText id="outputTextAddedRemoved" value="#{bundle['file.viewDiffDialog.files.header']}"/>
                            </div>
                            </ui:fragment>
                            <p:dataTable id="diffFilesDataTable" styleClass="dvnDifferanceTable"  value="#{DatasetPage.datasetVersionDifference.datasetFilesDiffList}" var="fileDiff"
                                         rendered="#{!empty(DatasetPage.datasetVersionDifference.datasetFilesDiffList)}">
                                <p:column styleClass="versionValue">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileID']} #{fileDiff.fileId}"/>
                                    <br></br>
                                    <h:outputText value="#{fileDiff.fileChecksumType} #{fileDiff.fileChecksumValue}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileDiff.file1Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileDiff.fileName1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileName1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileDiff.fileType1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileType1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileDiff.fileSize1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileSize1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileDiff.fileCat1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileCat1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileDiff.fileDesc1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileDesc1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileDiff.fileProvFree1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileProvFree1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.restricted']}: #{fileDiff.fileRest1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileRest1 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileDiff.file1Empty}">
                                    &#160;
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileDiff.file2Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileDiff.fileName2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileName2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileDiff.fileType2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileType2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileDiff.fileSize2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileSize2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileDiff.fileCat2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileCat2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileDiff.fileDesc2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileDesc2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileDiff.fileProvFree2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileProvFree2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.restricted']}: #{fileDiff.fileRest2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileRest2 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileDiff.file2Empty}">
                                    &#160;
                                </p:column>
                            </p:dataTable>
                            <ui:remove>
                            <!-- To:DO REMOVED SECOND FILES TABLE HEADER, UI CLEAN UP NEEDED IN FILE VERSIONS BRANCH -->
                            <ui:fragment rendered="#{!empty(DatasetPage.datasetVersionDifference.datasetFilesReplacementList)}">
                            <div class="panel-heading text-info" >
                                <h:outputText id="outputTextReplaced" value="#{bundle['file.viewDiffDialog.files.header']}"/>
                            </div>
                            </ui:fragment>
                            </ui:remove>
                            <p:dataTable id="replacemetFilesDataTable" style="border-top:1px solid #ddd;" styleClass="dvnDifferanceTable" value="#{DatasetPage.datasetVersionDifference.datasetFilesReplacementList}" var="fileReplace"
                                         rendered="#{!empty(DatasetPage.datasetVersionDifference.datasetFilesReplacementList)}">
                                <p:column styleClass="versionValue">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileReplaced']}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileReplace.fdi.file1Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileID']}: #{fileReplace.file1Id}" styleClass="diffDetailBlock" rendered="#{fileReplace.file1Id != null}"/>
                                    <h:outputText value="#{fileReplace.file1ChecksumType}: #{fileReplace.file1ChecksumValue}" styleClass="diffDetailBlock" rendered="#{fileReplace.file1Id != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileReplace.fdi.fileName1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileName1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileReplace.fdi.fileType1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileType1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileReplace.fdi.fileSize1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileSize1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileReplace.fdi.fileCat1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileCat1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileReplace.fdi.fileDesc1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileDesc1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileReplace.fdi.fileProvFree1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileProvFree1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.restricted']}: #{fileReplace.fdi.fileRest1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileRest1 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileReplace.fdi.file1Empty}">
                                    &#160;
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileReplace.fdi.file2Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileID']}: #{fileReplace.file2Id}" styleClass="diffDetailBlock" rendered="#{fileReplace.file2Id != null}"/>
                                    <h:outputText value="#{fileReplace.file2ChecksumType}: #{fileReplace.file2ChecksumValue}" styleClass="diffDetailBlock" rendered="#{fileReplace.file2Id != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileReplace.fdi.fileName2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileName2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileReplace.fdi.fileType2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileType2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileReplace.fdi.fileSize2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileSize2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileReplace.fdi.fileCat2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileCat2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileReplace.fdi.fileDesc2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileDesc2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileReplace.fdi.fileProvFree2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileProvFree2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.restricted']}: #{fileReplace.fdi.fileRest2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileRest2 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileReplace.fdi.file2Empty}">
                                    &#160;
                                </p:column>
                            </p:dataTable>
                        </div>
                        <div class="panel panel-default" jsf:rendered="#{!empty(DatasetPage.datasetVersionDifference.changedTermsAccess)}">
                            <div class="panel-heading text-info">
                                <h:outputText id="outputTextTOU" value="#{bundle['dataset.versionDifferences.termsOfUseAccess']}"/>
                            </div>
                            <p:dataTable id="changedTermsAccessTable" styleClass="dvnDifferanceTable" var="diffArray" value="#{DatasetPage.datasetVersionDifference.changedTermsAccess}">
                                <p:column styleClass="versionValue">
                                    <h:outputText value="#{diffArray[0]}"/>
                                </p:column>
                                <p:column styleClass="versionDetails">
                                    <h:outputText value="#{diffArray[1]}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" >
                                    <h:outputText value="#{diffArray[2]}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                        <div class="button-block margin-bottom">
                            <button class="btn btn-default" onclick="PF('detailsBlocks').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.done}
                            </button>
                        </div>
                    </p:dialog>
                    
                    <p:dialog id="selectFilesForDownload" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForDownload" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForDownload']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForDownload').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="selectFilesForRequestAccess" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForRequestAccess" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForRequestAccess']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForRequestAccess').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="selectFilesForDelete" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForDelete" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForDelete']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForDelete').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="selectFilesForRestrict" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForRestrict" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForRestrict']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForRestrict').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="selectFilesForUnRestrict" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForUnRestrict" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForUnRestrict']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForUnRestrict').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="selectFilesForEditMetadata" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForEditMetadata" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForMetadataEdit']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForEditMetadata').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="selectFilesForEditTags" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForEditTags" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForMetadataEdit']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForEditTags').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:remoteCommand  name="refreshTagsCommand" action="#{DatasetPage.refreshTagsPopUp()}" update=":datasetForm:fileTagsPopup"/>

                    <!-- We no longer need this remoteCommand; see my comments in the javascript method testFilesSelectedForEditMetadata() -->
                    <!-- for more info. - L.A. 4.2.1 -->
                    <!-- p:remoteCommand  name="openEditFilesPageCommand" action=" {DatasetPage.editFileMetadata()}"  / -->

                    <p:dialog id="fileTagsPopup" styleClass="smallPopUp" header="#{bundle['file.editTags']}" widgetVar="fileTagsPopup" modal="true">
                        <p:focus for="fileTagsMenuDS"/>
                        <p class="help-block">#{bundle['file.editTagsDialog.tip']}</p>
                        <div class="form-horizontal" jsf:rendered="#{!(empty DatasetPage.selectedFiles)}">
                            <div class="form-group text-left">
                                <label for="selectedTagsList" class="col-sm-4 control-label">
                                    #{bundle['file.editTagsDialog.selectedTags']}
                                </label>
                                <div class="col-sm-8">
                                    <p:outputPanel id="selectedTagsList" style="padding-top:.5em;">
                                        <h:outputText value="#{bundle['file.editTagsDialog.selectedTags.none']}" rendered="#{(empty DatasetPage.selectedTags) and (empty DatasetPage.selectedTabFileTags)}" />

                                        <ui:repeat value="#{DatasetPage.selectedTags}" var="tags" rendered="#{!empty DatasetPage.selectedTags}">
                                            <h:outputText value="#{tags}" styleClass="label label-default" style="margin-right:.5em;display:inline-block;"/>
                                        </ui:repeat>
                                        <ui:repeat value="#{DatasetPage.selectedTabFileTags}" var="tags" rendered="#{!empty DatasetPage.selectedTabFileTags}">
                                            <h:outputText value="#{tags}" styleClass="label label-info" style="margin-right:.5em;display:inline-block;"/>
                                        </ui:repeat>
                                    </p:outputPanel>
                                </div>
                            </div>
                            <div class="form-group text-left">
                                <label for="fileTagsMenuDS" class="col-sm-4 control-label">
                                    #{bundle['file.editTagsDialog.select']}
                                </label>
                                <div class="col-sm-8">
                                    <p:selectCheckboxMenu id="fileTagsMenuDS" styleClass="form-control"
                                                          value="#{DatasetPage.selectedTags}" label="#{bundle.select}">

                                        <p:ajax event="toggleSelect" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />
                                        <p:ajax event="change" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />

                                        <f:selectItems value="#{DatasetPage.categoriesByName}"/>
                                    </p:selectCheckboxMenu>
                                    <p:message for="fileTagsMenuDS" display="text" />
                                </div>
                            </div>
                            <div class="form-group text-left">
                                <label for="fileTagAddNewDS" class="col-sm-4 control-label">
                                    #{bundle['file.editTagsDialog.add']}
                                </label>
                                <div class="col-sm-8">
                                    <div class="row form-inline">
                                        <div class="col-sm-12">
                                            <p class="help-block">#{bundle['file.editTagsDialog.add.tip']}</p>
                                            <p:inputText id="fileTagAddNewDS" styleClass="form-control"
                                                         type="text" value="#{DatasetPage.newCategoryName}"
                                                         placeholder="#{bundle['file.editTagsDialog.newName']}"
                                                         onkeypress="if (event.keyCode == 13) {return false;}"/>
                                            <p:commandButton styleClass="btn btn-default" style="margin-left:.5em;" value="#{bundle.apply}" action="#{DatasetPage.saveNewCategory}" update="selectedTagsList, fileTagAddNewDS, fileTagsMenuDS"/>
                                        </div>
                                    </div>
                                    <p:message for="fileTagAddNewDS" display="text" />
                                </div>
                            </div>
                            <div class="form-group text-left" jsf:rendered="#{DatasetPage.tabularDataSelected}">
                                <label for="tabularDataTagsDSPage" class="col-sm-4 control-label">
                                    #{bundle['file.tabularDataTags']}
                                </label>
                                <div class="col-sm-8">
                                    <p class="help-block">#{bundle['file.tabularDataTags.tip']}</p>
                                    <p:selectCheckboxMenu id="tabularDataTagsDSPage" styleClass="form-control"
                                                          value="#{DatasetPage.selectedTabFileTags}" label="#{bundle.select}"
                                                          filter="false">

                                        <p:ajax event="toggleSelect" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />
                                        <p:ajax event="change" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />

                                        <f:selectItems value="#{DatasetPage.tabFileTags}" />
                                    </p:selectCheckboxMenu>
                                    <p:message for="tabularDataTagsDSPage" display="text" />
                                </div>
                            </div>
                            <div class="form-group text-left">
                                <label class="col-sm-4 control-label">
                                    #{bundle['dataset.removeUnusedFileTags.label']}
                                </label>
                                <div class="col-sm-8">
                                    <p class="help-block">#{bundle['dataset.removeUnusedFileTags.tip']}</p>
                                    <p:selectBooleanCheckbox id="removeUnused" itemLabel="#{bundle['dataset.removeUnusedFileTags.check']}" value="#{DatasetPage.removeUnusedTags}" widgetVar="removeUnused"/>
                                </div>
                            </div>
                        </div>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" id="fileTagsPopupSaveButton" value="#{bundle.saveChanges}" oncomplete="PF('fileTagsPopup').hide()" update=":datasetForm:tabView:filesTable, :datasetForm" action="#{DatasetPage.saveFileTagsAndCategories()}"/>
                            <p:commandButton styleClass="btn btn-link" id="fileTagsPopupCancelButton" value="#{bundle.cancel}" onclick="PF('fileTagsPopup').hide();PF('blockDatasetForm').hide();" actionListener="#{DatasetPage.clearFileMetadataSelectedForTagsPopup()}"/>
                        </div>
                    </p:dialog>
                    <!-- Request Access Sign Up/Log In Button -->
                    <p:dialog id="accessSignUpLogIn" header="#{bundle['file.requestAccess']}" widgetVar="accessSignUpLogIn_popup" modal="true">
                        <p class="help-block">
                            <span class="glyphicon glyphicon-warning-sign text-danger"/>&#160;
                            <h:outputFormat styleClass="text-danger" value="#{dataverseHeaderFragment.signupAllowed ? bundle['file.requestAccess.dialog.msg.signup'] : bundle['file.requestAccess.dialog.msg']}" escape="false">
                                <f:param value="#{navigationWrapper.redirectPage}"/>
                                <f:param value="#{dataverseHeaderFragment.getSignupUrl(navigationWrapper.redirectPage)}"/>
                                <f:param value="#{widgetWrapper.widgetView ? '_blank' : '_self'}"/>
                            </h:outputFormat>
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('accessSignUpLogIn_popup').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <!-- END: Request Access Sign Up/Log In Button -->
                    <p:dialog id="configureToolPopup" styleClass="smallPopUp" header="#{configureFragmentBean.configurePopupToolHandler.externalTool.displayName}" widgetVar="configureToolPopup" modal="true">
                        <ui:include src="file-configure-popup-fragment.xhtml">
                            <ui:param name="canUpdateDataset" value="#{DatasetPage.canUpdateDataset()}"/>
                        </ui:include>
                    </p:dialog>
                    <p:dialog id="downloadPopup" styleClass="largePopUp" header="#{bundle['file.downloadDialog.header']}" widgetVar="downloadPopup" modal="true">
                        <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                        <ui:include src="file-download-popup-fragment.xhtml">
                            <ui:param name="workingVersion" value="#{DatasetPage.workingVersion}"/>
                            <ui:param name="downloadPopupRequired" value="#{DatasetPage.downloadPopupRequired}"/>
                            <ui:param name="guestbookResponse" value="#{DatasetPage.fileDownloadHelper.guestbookResponse}" rendered="#{!settingsWrapper.rsyncDownload}"/>
                            <ui:param name="fileDownloadHelper" value="#{DatasetPage.fileDownloadHelper}"/>
                            <ui:param name="fileDownloadService" value="#{DatasetPage.fileDownloadService}"/>
                        </ui:include>
                    </p:dialog>
                    <p:dialog id="downloadPackagePopup" styleClass="smallPopUp" header="#{bundle['packageDownload.title']}" widgetVar="downloadPackagePopup" modal="true">
                        <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                        <ui:include src="package-download-popup-fragment.xhtml">
                            <ui:param name="workingVersion" value="#{DatasetPage.workingVersion}"/>
                            <ui:param name="downloadPopupRequired" value="#{DatasetPage.downloadPopupRequired}"/>
                            <ui:param name="guestbookResponse" value="#{DatasetPage.fileDownloadHelper.guestbookResponse}" rendered="#{!settingsWrapper.rsyncDownload}"/>
                            <ui:param name="fileDownloadHelper" value="#{DatasetPage.fileDownloadHelper}"/>
                            <ui:param name="fileDownloadService" value="#{DatasetPage.fileDownloadService}"/>
                        </ui:include>
                    </p:dialog>
                    <p:dialog id="requestAccessPopup" styleClass="largePopUp" header="#{bundle['file.requestAccess']}" widgetVar="requestAccessPopup" modal="true">
                        <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                        <ui:include src="file-request-access-popup-fragment.xhtml">
                            <ui:param name="workingVersion" value="#{DatasetPage.workingVersion}"/>
                            <ui:param name="fileDownloadHelper" value="#{DatasetPage.fileDownloadHelper}"/>
                            <ui:param name="fileDownloadService" value="#{DatasetPage.fileDownloadService}"/>
                        </ui:include>
                    </p:dialog>
                    <p:dialog id="linkDatasetForm" styleClass="largePopUp" header="#{bundle['dataset.link']}" widgetVar="linkDatasetForm" modal="true" rendered="#{DatasetPage.showLinkingPopup}">
                        <p:focus for="dataverseLinkName"/>
                        <div class="form-horizontal">
                            <p class="help-block">
                                <h:outputFormat value="#{bundle['dataverse.link.dataset.choose']}" escape="false">
                                    <o:param>
                                        <p:commandLink value="#{settingsWrapper.supportTeamName}" oncomplete="PF('linkDatasetForm').hide();PF('contactForm').show()" update=":contactDialog" actionListener="#{sendFeedbackDialog.initUserInput}">
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{null}"/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                        </p:commandLink>                                
                                    </o:param>
                                </h:outputFormat>
                            </p>
                            <div class="form-group">
                                <label class="col-xs-3 control-label">
                                    <h:outputText value="#{bundle['dataverse.link.yourDataverses']}"/>
                                </label>
                                <div class="col-xs-8">
                                    <p:fragment id="linkNameContent">
                                    <p:autoComplete id="dataverseLinkName" style="width:75%;"
                                                    binding="#{DatasetPage.selectedDataverseMenu}"
                                                    placeholder="#{bundle['dataverse.link.yourDataverses.inputPlaceholder']}"
                                                    emptyMessage="#{bundle['dataverse.link.dataset.none']}"
                                                    scrollHeight="180" forceSelection="true" 
                                                    minQueryLength="1" queryDelay="1000"
                                                    value="#{DatasetPage.selectedDataverseForLinking}" 
                                                    multiple="false"
                                                    completeMethod="#{DatasetPage.completeLinkingDataverse}"
                                                    required="#{param['DO_DS_LINK_VALIDATION']}" requiredMessage="#{bundle['dataverse.link.select']}"
                                                    styleClass="DropdownPopup" panelStyleClass="DropdownPopupPanel"
                                                    var="dataverseLk" itemLabel="#{dataverseLk.displayName}" itemValue="#{dataverseLk}" converter="dataverseConverter">
                                        <p:column>
                                            <h:outputText value="#{dataverseLk.displayName}"/> 
                                        </p:column>
                                        <p:column>
                                            <h:outputText value="#{dataverseLk.alias}"/> 
                                        </p:column>
                                        <p:ajax process="@this" event="itemSelect" />
                                        <p:ajax process="@this" event="itemUnselect" />
                                    </p:autoComplete>
                                    <p:message for="dataverseLinkName"/>
                                     </p:fragment>  
                                </div>
                            </div>
                        </div>
                        <div class="button-block">
                            <p:commandButton id="saveLinkButton" styleClass="btn btn-default"    
                                           update="linkNameContent @([id$=Messages])" 
                                           oncomplete="if (args &amp;&amp; !args.validationFailed) linkDatasetCommand();"
                                           value="#{bundle['dataset.link.save']}">  
                                <f:param name="DO_DS_LINK_VALIDATION" value="true"/>
                            </p:commandButton>
                            <button class="btn btn-link" onclick="PF('linkDatasetForm').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    
                    <p:remoteCommand name="linkDatasetCommand" oncomplete="PF('linkDatasetForm').hide();" update=":messagePanel  @([id$=Messages])" actionListener="#{DatasetPage.saveLinkingDataverses}"/>

                    <p:dialog id="computeBatchListPopup" header="#{bundle['dataset.compute.computeBatchListHeader']}" widgetVar="computeBatchListPopup" modal="true">
                        <div class="text-right">
                            <!-- Clear link -->
                            <p:commandButton styleClass="btn btn-default" action="#{DatasetPage.clearCart()}" update=":datasetForm,:messagePanel">
                                <span class="glyphicon glyphicon-remove"/> <h:outputText value="#{bundle['dataset.compute.computeBatchClear']}"/>
                            </p:commandButton>
                        </div>
                        <h:dataTable id="computeBatch" class="table table-striped" value="#{DatasetPage.cartList}" var='computeCartDatasetList'>
                            <h:column>
                                <f:facet name="header">#{bundle.dataset}</f:facet>
                                <h:outputText value="#{computeCartDatasetList.key}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{bundle['dataset.metadata.persistentId']}</f:facet>
                                <h:outputText value="#{computeCartDatasetList.value}"/>
                            </h:column>
                            <h:column>
                                <p:commandButton value="#{bundle['dataset.compute.computeBatchRemove']}" action="#{DatasetPage.removeCartItem(computeCartDatasetList.key, computeCartDatasetList.value)}" update=":datasetForm,:messagePanel"/>
                            </h:column>
                        </h:dataTable>
                        <div class="button-block">
                            <h:outputLink styleClass="btn btn-default" value="#{DatasetPage.cartComputeUrl}" onclick="PF('computeBatchListPopup').hide()" target="_blank">
                                <h:outputText value="#{bundle['dataset.compute.computeBatchCompute']}"/>
                            </h:outputLink>
                            <button class="btn btn-link" onclick="PF('computeBatchListPopup').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="accessPopup" header="#{bundle['dataset.access.accessHeader']}"  widgetVar="accessPopup" modal="true">
                        <ui:fragment rendered="#{DatasetPage.editMode == 'CREATE' or empty DatasetPage.editMode }">
                            <p:focus for="termsAccessInput"/>
                            <div class="form-horizontal">
                                <div class="form-group">
                                    <label for="metadata_TermsAccess" class="col-sm-3 control-label">
                                        #{bundle['file.dataFilesTab.terms.list.termsOfAccess.termsOfsAccess']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.termsOfsAccess.title']}"></span>
                                    </label>
                                    <div class="col-sm-9">
                                        <p:inputTextarea id="termsAccessInput" value="#{DatasetPage.workingVersion.termsOfUseAndAccess.termsOfAccess}" autoResize="false" rows="5" styleClass="form-control" widgetVar="inputtoa"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="metadata_RequestAccess" class="col-sm-3 control-label">
                                        #{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess']}
                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                              data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.title']}"></span>
                                    </label>
                                    <div class="col-sm-9">
                                        <p:selectBooleanCheckbox id="requestAccess" itemLabel="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.enableBtn']}"
                                                                 value="#{DatasetPage.workingVersion.termsOfUseAndAccess.fileAccessRequest}" widgetVar="inputfar"/>
                                    </div>
                                </div>
                            </div>
                            <div class="button-block">
                                <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" rendered="#{DatasetPage.editMode != 'CREATE'}"
                                                    onclick="PF('accessPopup').hide()" update=":datasetForm,:messagePanel" action="#{DatasetPage.restrictSelectedFiles(true)}"/>
                                <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" rendered="#{DatasetPage.editMode == 'CREATE'}"
                                                    onclick="PF('accessPopup').hide()" update=":datasetForm,:messagePanel" action="#{DatasetPage.save()}"/>
                                <!--<button class="btn btn-link" onclick="PF('accessPopup').hide();PF('blockDatasetForm').hide();" type="button">
                                    #{bundle.cancel}
                                </button>-->
                                <p:commandButton styleClass="btn btn-link" value="#{bundle.cancel}"
                                                 onclick="PF('accessPopup').hide();PF('blockDatasetForm').hide();" update=":datasetForm:accessPopup" action="#{DatasetPage.cancelAccessPopup()}"/>
                            </div>
                        </ui:fragment>
                    </p:dialog>

                    <p:dialog id="inreview" header="#{bundle['dataset.submitBtn']}" widgetVar="inreview" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.submitMessage']}
                        </p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.submit}" 
                                             onclick="PF('inreview').hide();PF('blockDatasetForm').hide();" action="#{DatasetPage.submitDataset}" immediate="true"/>
                            <button class="btn btn-link" onclick="PF('inreview').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>

                    <!-- Publish/Submit for Review Dialogs -->
                    <p:dialog id="publishConfirm" width="70%" header="#{bundle['dataset.publish.header']}" widgetVar="publishConfirm" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.publish.tip']}
                        </p>
                        <div id="terms-agreement-block" class="well" jsf:rendered="#{DatasetPage.datasetPublishCustomText.length() > 0}">
                            <h:outputText value="#{DatasetPage.datasetPublishCustomText}" escape="false"/>
                        </div>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" 
                                             onclick="PF('publishConfirm').hide();PF('blockDatasetForm').hide();" action="#{DatasetPage.releaseDataset}" immediate="true"/>
                            <button class="btn btn-link" onclick="PF('publishConfirm').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="publishParent" width="70%" header="#{bundle['dataset.publish.header']}" widgetVar="publishParent" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/>
                            <h:outputFormat value="#{bundle['dataset.mayNotPublish.both']}" escape="false">
                                <o:param>
                                    <a href="/dataverse/#{DatasetPage.dataset.owner.alias}" title="#{DatasetPage.dataset.owner.displayName}">
                                        <h:outputText value="#{DatasetPage.dataset.owner.displayName}"/>
                                    </a>
                                </o:param>
                            </h:outputFormat>
                        </p>
                        <div id="terms-agreement-block" class="well" jsf:rendered="#{DatasetPage.datasetPublishCustomText.length() > 0}">
                            <h:outputText value="#{MarkupChecker:sanitizeBasicHTML(DatasetPage.datasetPublishCustomText)}" escape="false"/>
                        </div>
                        <p class="help-block">
                            #{bundle['dataset.publishBoth.tip']}
                        </p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle['dataset.mayNotBePublished.both.button']}" 
                                             onclick="PF('publishParent').hide();PF('blockDatasetForm').hide();" action="#{DatasetPage.releaseParentDVAndDataset}" immediate="true"/>
                            <button class="btn btn-link" onclick="PF('publishParent').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="releaseDraft" width="70%" header="#{bundle['dataset.publish.header']}" widgetVar="releaseDraft" modal="true">
                        <p:focus for="options"/>
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.republish.tip']}
                        </p>
                        <div id="terms-agreement-block" class="well" jsf:rendered="#{DatasetPage.datasetPublishCustomText.length() > 0 and DatasetPage.isDatasetPublishPopupCustomTextOnAllVersions()}">
                            <h:outputText value="#{MarkupChecker:sanitizeBasicHTML(DatasetPage.datasetPublishCustomText)}" escape="false"/>
                        </div>
                        <ui:fragment rendered="#{DatasetPage.dataset.latestVersion.minorUpdate}">
                            <p class="help-block">
                                #{bundle['dataset.selectVersionNumber']}
                            </p>
                            <p:selectOneRadio id="options" value="#{DatasetPage.releaseRadio}">
                                <f:selectItem itemLabel="#{bundle['dataset.minorRelease']} (#{DatasetPage.datasetNextMinorVersion})" itemValue="1" />
                                <f:selectItem itemLabel="#{bundle['dataset.majorRelease']} (#{DatasetPage.datasetNextMajorVersion})" itemValue="2" />
                                <c:if test="#{dataverseSession.user.isSuperuser()}">
                                    <f:selectItem rendered="#" itemLabel="#{bundle['dataset.updateRelease']}" itemValue="3" />
                                </c:if>
                            </p:selectOneRadio>
                        </ui:fragment>
                        <p>
                            <h:outputFormat value="#{bundle['dataset.majorRelease.tip']}" rendered="#{!DatasetPage.dataset.latestVersion.minorUpdate}">
                                <f:param value="#{DatasetPage.datasetNextMajorVersion}"/>
                            </h:outputFormat>
                        </p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" 
                                             rendered="#{DatasetPage.dataset.latestVersion.minorUpdate}"
                                             onclick="PF('releaseDraft').hide();PF('blockDatasetForm').hide();" action="#{DatasetPage.releaseDraft}"/>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" 
                                             rendered="#{!DatasetPage.dataset.latestVersion.minorUpdate}"
                                             onclick="PF('releaseDraft').hide();PF('blockDatasetForm').hide();" action="#{DatasetPage.releaseMajor}" immediate="true"/>
                            <button class="btn btn-link" onclick="PF('releaseDraft').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="mayNotRelease" header="#{bundle['dataset.publish.header']}" widgetVar="mayNotRelease" modal="true">
                        <p class="text-danger">
                            <span class="glyphicon glyphicon-exclamation-sign"/>
                            <h:outputFormat value="#{bundle['dataset.mayNotPublish.administrator']}" escape="false">
                                <o:param>
                                    <a href="/dataverse.xhtml?alias=#{DatasetPage.dataset.owner.alias}" title="#{DatasetPage.dataset.owner.displayName}">
                                        <h:outputText value="#{DatasetPage.dataset.owner.displayName}"/>
                                    </a>
                                </o:param>
                            </h:outputFormat>
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('mayNotRelease').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="maynotPublishParent" header="#{bundle['dataset.publish.header']}" widgetVar="maynotPublishParent" modal="true">
                        <p class="text-danger">
                            <span class="glyphicon glyphicon-exclamation-sign"/>
                            <h:outputFormat value="#{bundle['dataset.mayNotPublish.twoGenerations']}" escape="false">
                                <o:param>
                                    <a href="/dataverse/#{DatasetPage.dataset.owner.alias}" title="#{DatasetPage.dataset.owner.displayName}">
                                        <h:outputText value="#{DatasetPage.dataset.owner.displayName}"/>
                                    </a>
                                </o:param>
                                <o:param>
                                    <a href="/dataverse/#{DatasetPage.dataset.owner.owner.alias}" title="#{DatasetPage.dataset.owner.owner.displayName}">
                                        <h:outputText value="#{DatasetPage.dataset.owner.owner.displayName}"/>
                                    </a>
                                </o:param>
                            </h:outputFormat>
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('maynotPublishParent').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                    <p:dialog id="sendBackToContributor" header="#{bundle['dataset.rejectBtn']}" widgetVar="sendBackToContributor" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.rejectMessage']}
                        </p>
                        <ui:remove>
                        <!--FIXME update for new comments table -->
                        <p:inputTextarea id="returnReason" rows="3" value="#{DatasetPage.workingVersion.returnReason}" maxlength="200" widgetVar="returnReason"
                                         cols="70" counter="display" counterTemplate="{0} characters remaining." autoResize="false"
                                         requiredMessage="#{bundle['dataset.reject.enterReason.error']}"/>
                        <!--FIXME validation error msg for returnReason was in confirmDialog using testReturnReason() in commandButton below but all that was removed
                                  as it did not look like the usual validation method, added preferred requiredMessage attribute to inputTextarea above, need wiring #5717-->
                        <p>
                            <h:outputText id="display"/>
                        </p>
                        <p:watermark for="returnReason" value="#{bundle['dataset.rejectWatermark']}" id="returnReasonwatermark"/>
                        </ui:remove>

                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('sendBackToContributor').hide()" action="#{DatasetPage.sendBackToContributor}"/>
                            <button class="btn btn-link" onclick="PF('sendBackToContributor').hide();PF('blockDatasetForm').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:remoteCommand name="returnToAuthorCommand" action="#{DatasetPage.sendBackToContributor}"/>                  
                    <!-- END: Publish/Submit for Review Dialogs -->

                    <!-- add by yqpeng2, 2019-12-28, 增加文件被删除或被替换时不能被编辑的提示框 -->
                    <p:dialog id="fileAlreadyReplacedOrDeletedPrevious" styleClass="smallPopUp"
                              header="#{bundle['file.replaced.warning.header']}" widgetVar="fileAlreadyReplacedOrDeletedPrevious" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['file.alreadyReplacedDeleted.previous.warningMessage']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('fileAlreadyReplacedOrDeletedPrevious').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>

                </h:form>
                <script>
                    //<![CDATA[
                    $(document).ready(function () {
                        popoverHTML('#{bundle.htmlAllowedTitle}');
                    });
                    
                    function openDialog() {
                        PF('details').show();
                    }
                    function openCompareTwo() {
                        PF('compareTwo').show();
                    }
                    function testCheckBoxes() {
                        var count = PF('versionsTable').getSelectedRowsCount();
                        if (count !== 2) {
                            PF('compareTwo').show();
                        } else {
                            $('button[id$="compareVersions"]').trigger('click');
                        }
                    }
                    function testFilesSelectedForRestriction() {
                        var count = PF('filesTable').getSelectedRowsCount();
                        if (count === 0) {
                            PF('selectFilesForRestrict').show();
                        } else {
                            PF('accessPopup').show();
                        }

                    }
                    function testFilesSelectedForTags() {
                        var count = PF('filesTable').getSelectedRowsCount();
                        if (count === 0) {
                            PF('selectFilesForEditTags').show();
                        } else {
                            refreshTagsCommand();
                        }
                    }
                    function testFilesSelectedForDelete() {
                        var count = PF('filesTable').getSelectedRowsCount();
                        if (count === 0) {
                            PF('selectFilesForDelete').show();
                        } else {
                            PF('deleteSelectedFileConfirmation').show();
                        }
                    }
                    function testFilesSelectedForEditMetadata() {
                        var count = PF('filesTable').getSelectedRowsCount();
                        if (count === 0) {
                            PF('selectFilesForEditMetadata').show();
                        } //else {
                        // I commented out the code below; if there's
                        // 1 or more file selected, I don't want this
                        // method to activate the p:remoteCommand that
                        // issues the redirect to the edit page (or
                        // do anything else for that matter). Doing
                        // it this way was, for some reason, causing
                        // this page to still try to render (??), in
                        // some partial, half-baked state - with no
                        // workingVersion present, etc. - that resulted
                        // in some NULL pointers in the logs... So,
                        // instead, the redirect will be done by the
                        // direct action= attribute in the original
                        // commandButton. -- L.A. 4.2.1
                        //openEditFilesPageCommand();
                        //}
                    }
                    function updateTemplate() {
                        $('button[id$="updateTemplate"]').trigger('click');
                    }
                    function checkNewlyRestricted() {
                        if ($('input[id$="showAccessPopup"]').val() === 'true') {
                            PF('accessPopup').show();
                        } else {
                            $('button[id$="datasetSave"]').trigger('click');
                        }
                    }
                    function updateHiddenReason(textArea) {
                        $('input[id$="hiddenReasonInput"]').val(textArea.value);
                    }
                    //]]>
                </script>
            </ui:define>
        </ui:composition>
    </h:body>
</html>